package ru.rchervot.sanasar.client.view;

import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;

public abstract class AbstractRecordView extends Composite 
implements RecordPresenter.Display {
	protected VerticalPanel basePanel = new VerticalPanel();
	protected HTML itemView = new HTML();
	protected Widget itemDescriptionView;
	
	private Presenter presenter;
	
	public AbstractRecordView(Widget itemDescriptionView) {
		super();
		
		this.itemDescriptionView = itemDescriptionView;
		
		basePanel.setStylePrimaryName("AbstractRecordView");
		basePanel.add(itemDescriptionView);
		basePanel.add(itemView);
		basePanel.setSize("100%", "100%");
		this.initWidget(basePanel);
	}
	
	@Override
	public void setPresenter(Presenter presenter) {
		this.presenter = presenter;
	}
	
	@Override
	public void showEmptyItem() {
		itemDescriptionView.setVisible(false);
		itemView.setHTML("Item was not found");
	}

	@Override
	public void showItem(String item) {
		itemDescriptionView.setVisible(true);
		itemView.setHTML(item);
	}
	
}
